package com.easy.project.config.file;

import io.minio.MinioClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * MinioClient 基础配置类
 */
@Configuration
@ConditionalOnProperty(name = "file.type",havingValue = "MINIO")
public class MinioClientConfig {

    @Resource
    private FileConfig minioConfig;

    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder()
                .endpoint(minioConfig.getEndpoint())
                .credentials(minioConfig.getMinioAccessKey(), minioConfig.getMinioSecretKey())
                .build();
    }
}
